package org.naivecoders.ai.functions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.naivecoders.ai.types.MaybeBowl;

public abstract class AbstractFunction {
	private List<AbstractFunction> inputs;

	public abstract MaybeBowl evaluate();

	public AbstractFunction(AbstractFunction... inputs) {
		setInputs(inputs);
	}

	public void setInputs(AbstractFunction... functions) {
		inputs = new ArrayList<AbstractFunction>(Arrays.asList(functions));
	}

	protected Collection<AbstractFunction> getInputs() {
		return inputs;
	}

	public void addInput(AbstractFunction i) {
		inputs.add(i);
	}

	public void removeInput(AbstractFunction i) {
		inputs.remove(i);
	}

	@SuppressWarnings("unchecked")
	protected <T extends AbstractFunction> T getInput(int i) {
		return (T) inputs.get(i);
	}
}
